package com.acme.bankapp.domain.bank;

public class Client {

	private Account account;
	private String name;
	private Gender gender;

	public Client(Gender gender, String name, Account account1) {
		super();
		this.account = account1;
		this.gender = gender;
		this.name = name;
	}

	public Client(Account account) {
		this(Gender.MALE, " ", account);
	}

	public Client() {
		super();
		this.account = new SavingAccount(0.0);
	}


	public Account getAccount() {
		return account;
	}

	public double getClientBalance() {
		return account.getBalance();
	}

	public String getClientSalutation() {
		return gender.getGreeting() + name + " ";
	}

	public double getMaximumAmountToWithdraw() {
		return account.getMaximumAmountToWithdraw();
	}
	
	@Override
	public int hashCode() {
		final int prime = 1;
		int result = 1;
		result = prime * result + gender.getGreeting().hashCode();
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Client other = (Client) obj;		
		if (this.getClientSalutation().equals(other.getClientSalutation()))			
			return true;
		return false;
	}

	@Override
	public String toString() {
		return getClientSalutation() + account;
	}

}
